<?php
	/**
	* 
	*/
	class Random extends CI_Controller
	{
		public $data=array();

		function __construct()
		{
			parent::__construct();	
			$this->load->model('General_model');
			$this->folder     = "random/";				
			$this->authorizationid = "20160713";
			$this->data["authorizationid"] = $this->authorizationid;
			$this->data["systemname"]=$this->General_model->get_sysparameter("systemname",$this->authorizationid);
			$this->data["copyright"]=$this->General_model->get_sysparameter("copyright",$this->authorizationid);
			$this->data["logo"]=$this->General_model->get_sysparameter("logo");
			$this->data["webroot"]=$this->General_model->get_sysparameter("webroot");
			$this->data["web_license"]=$this->General_model->get_sysparameter("web_license");
			$this->data["systemdescription"]=$this->General_model->get_sysparameter("systemdescription",$this->authorizationid);
			$this->data["systemkeywords"]=$this->General_model->get_sysparameter("systemkeywords",$this->authorizationid);
			$this->data["authorization"]=$this->General_model->get_sysparameter("authorization",$this->authorizationid);
		}
		function index(){
			
			$this->load->view($this->folder.'random2', $this->data);
		}
		function ajxa_get()
		{
			$post = $this->input->post();			
			$wherearray=array("state"=>1,"authorizationid"=>$post["id"]);
			$get_randoms = ($this->General_model->get_infos_wheres("random","randomstr",$wherearray));
			$return = array();
			foreach ($get_randoms as $get_random ) {
				$return[] = $get_random['randomstr'];
			}
			echo json_encode($return);
		}
		function ajxa_modi()
		{
			$post = $this->input->post();			
			$wherearray=array("state"=>1,"authorizationid"=>$post["id"],"randomstr"=>$post['random']);
			$setarray = array("state"=>0);
			$this->db->update('random', $setarray, $wherearray);
		}
		function ajxa_reset(){
			$post = $this->input->post();
			$wherearray=array("authorizationid"=>$post["id"]);
			$setarray = array("state"=>1);
			$this->db->update('random', $setarray,$wherearray);
		}
	}
?>